home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / demostu2 / mouse.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-12-13  |  3.6 KB  |  194 lines

  1. UNIT MOUSE;
  2. {
  3.     Mouse
  4.     - by Bjarke Viksoe
  5.  
  6.     One of the standard "hey, I can handle the mouse, too" units.
  7. }
  8.  
  9.  
  10. INTERFACE
  11.  
  12. function InitMouse : boolean;
  13. {Initialize mouse to its default values for current screenmode.
  14.  Mouse is turned off.
  15.  Returns TRUE if mouse is present.}
  16. function MouseDriverPresent : boolean;
  17. {Returns TRUE if there were a mouse driver out there...}
  18. procedure MouseOn;
  19. {Turns mouse image on}
  20. procedure MouseOff;
  21. {Turns mouse image off}
  22. procedure MouseInfo(VAR x,y : integer; VAR lb,rb : boolean);
  23. {Get information about current x- and y-positions.
  24.  Also return info about current status of mouse buttons}
  25. function LeftButton : boolean;
  26. {Retuns TRUE if left mouse button is pressed}
  27. function RightButton : boolean;
  28. {Retuns TRUE if right mouse button is pressed}
  29. procedure LastButtonPress(button : integer; VAR x,y : integer);
  30. {Returns last x/y mouse pos when 'button' was pressed}
  31. procedure LastButtonRelease(button : integer; VAR x,y : integer);
  32. {Returns last x/y mouse pos when 'button' was released}
  33. procedure SetMousePos(x,y : integer);
  34. {Set mouse position on screen...}
  35. procedure SetMouseWindow(x1,y1,x2,y2 : integer);
  36. {Set mouse window limit}
  37. procedure SetMouseImage(hotx,hoty : integer; Image : pointer);
  38. {Change mouse pointer image.
  39.  "Hot?" ranges from -16 to 16
  40.  "Image" is 16 words of mask + 16 words of image}
  41. procedure ReadMouseMotionCounters(VAR x,y : integer);
  42. {Read mouse's motion counters}
  43. procedure DefineMouseRatio(h,v : word);
  44. {Change mouse Mickey/pixel ratio}
  45.  
  46.  
  47. IMPLEMENTATION
  48.  
  49. function InitMouse : boolean; assembler;
  50. asm
  51.     xor    ax,ax
  52.     int    $33
  53.     not    ax
  54.     xor    ax,1
  55.     and    ax,1
  56. end;
  57.  
  58. function MouseDriverPresent : boolean; assembler;
  59. asm
  60.     mov    ax,$21 {try to reset mouse}
  61.     int    $33
  62.     cmp    ax,-1
  63.     je        @found
  64.     mov    ax,$0    {not there. might be bad driver version... try setup mouse}
  65.     int    $33
  66.     push    ax
  67.     mov    ax,$2    {quickly hide it again}
  68.     int    $33
  69.     pop    ax
  70. @found:
  71.     inc    ax
  72.     xor    ax,1
  73. end;
  74.  
  75. procedure MouseOn; assembler;
  76. asm
  77.     mov    ax,$0001
  78.     int    $33
  79. end;
  80.  
  81. procedure MouseOff; assembler;
  82. asm
  83.     mov    ax,$0002
  84.     int    $33
  85. end;
  86.  
  87. procedure MouseInfo(VAR x,y : integer; VAR lb,rb : boolean); assembler;
  88. asm
  89.     mov    ax,$0003
  90.     int    $33
  91.     les    si,x
  92.     mov    [es:si],cx
  93.     les    si,y
  94.     mov    [es:si],dx
  95.  
  96.     mov    ax,bx
  97.     and    al,1
  98.     les    si,lb
  99.     mov    [es:si],al
  100.     shr    bl,1
  101.     and    bl,1
  102.     les    si,rb
  103.     mov    [es:si],bl
  104. end;
  105.  
  106. function LeftButton : boolean; assembler;
  107. asm
  108.     mov    ax,3
  109.     int    $33
  110.     mov    ax,bx
  111.     and    ax,1
  112. end;
  113.  
  114. function RightButton : boolean; assembler;
  115. asm
  116.     mov    ax,3
  117.     int    $33
  118.     mov    ax,bx
  119.     shr    ax,1
  120.     and    ax,1
  121. end;
  122.  
  123. procedure LastButtonPress(button : integer; VAR x,y : integer); assembler;
  124. asm
  125.     mov    ax,5
  126.     mov    bx,button
  127.     int    $33
  128.     les    di,x
  129.     mov    [es:di],cx
  130.     les    di,y
  131.     mov    [es:di],dx
  132. end;
  133.  
  134. procedure LastButtonRelease(button : integer; VAR x,y : integer); assembler;
  135. asm
  136.     mov    ax,6
  137.     mov    bx,button
  138.     int    $33
  139.     les    di,x
  140.     mov    [es:di],cx
  141.     les    di,y
  142.     mov    [es:di],dx
  143. end;
  144.  
  145. procedure SetMousePos(x,y : integer); assembler;
  146. asm
  147.     mov    ax,$0004
  148.     mov    cx,x
  149.     mov    dx,y
  150.     int    $33
  151. end;
  152.  
  153. procedure SetMouseWindow(x1,y1,x2,y2 : integer); assembler;
  154. asm
  155.     mov    ax,$0007
  156.     mov    cx,x1
  157.     mov    dx,x2
  158.     int    $33
  159.     mov    ax,$0008
  160.     mov    cx,y1
  161.     mov    dx,y2
  162.     int    $33
  163. end;
  164.  
  165. procedure SetMouseImage(hotx,hoty : integer; Image : pointer); assembler;
  166. asm
  167.     mov    ax,$0009
  168.     mov    bx,hotx
  169.     mov    cx,hoty
  170.     les    dx,Image
  171.     int    $33
  172. end;
  173.  
  174. procedure DefineMouseRatio(h,v : word); assembler;
  175. asm
  176.     mov    ax,$000F
  177.     mov    cx,h
  178.     mov    dx,v
  179.     int    $33
  180. end;
  181.  
  182. procedure ReadMouseMotionCounters(VAR x,y : integer); assembler;
  183. asm
  184.     mov    ax,$000B
  185.     int    $33
  186.     les    di,x
  187.     mov    [es:di],cx
  188.     les    di,y
  189.     mov    [es:di],dx
  190. end;
  191.  
  192.  
  193. end.
  194.